<?php
class AdminModel extends Model
{
	static public function getAdminList()
	{
		$Admin = M('Admin');
		return $Admin->select();
	}

	static public function getAdminInfo($options)
	{
		$Admin = M('Admin');
		return $Admin->where($options)->find();
	}

	static public function addAdmin($params)
	{
		$Admin = M('Admin');
		return $Admin->add($params);
	}
	
	static public function updateAdmin($options, $data)
	{
		$Admin = M('Admin');
		return $Admin->where($options)->save($data);
	}

	static public function delAdmin($admin_id)
	{
		$Admin = M('Admin');
		$options['id'] = $admin_id;
		return $Admin->where($options)->delete();
	}

	static public function getAdminRole($id)
	{
		$Admin = M('Admin');
		$res = $Admin->where("id=".$id)->find();
		switch($res['level']){
			case 1:return '系统管理员';break;
			case 2:return '商品管理员';break;
			case 3:return '财务管理员';break;
			case 4:return '订单管理员';break;
			case 5:return '运营管理员';break;
			case 6:return '用户管理员';break;
			case 99:return '超级管理员';break;
		}
	}

	static public function setLoginTime($admin_id)
	{
		$data['last_time'] = time();
		$map['id'] = $admin_id;
		$Admin = M('Admin');
		$Admin->where($map)->save($data);
	}


}